package com.kun.springbootdelivery.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class DeadLetterQueueConfig {

    //创建交换机
    @Bean
    public FanoutExchange deadLetterExchange() {
        return new FanoutExchange("dead-letter-exchange");
    }

    //创建队列
    @Bean
    public Queue deadLetterQueue() {

        return new Queue("dead-letter-queue-1", true, false,false);
    }

    //绑定队列到交换机
    @Bean
    public Binding bindingDeadLetter() {
        return BindingBuilder.bind(deadLetterQueue()).to(deadLetterExchange());
    }

}
